package com.thwcompany.config1;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

//发布-订阅模式
@Configuration
@SuppressWarnings("all")
public class ProducerMessageExchangeConfig {
	@Bean
 	public DirectExchange directPmcExchange(){
		DirectExchange directExchange=new DirectExchange("direct-pmc-exchange");
 		return directExchange;
 	}
	
	@Bean
    public Queue directPmcQueue() {
		Map<String, Object> arguments = new HashMap<String, Object>();
		arguments.put("x-message-ttl", 10000);
		//Queue queue=new Queue("direct-pmc-queue");
		Queue queue=new Queue("direct-pmc-queue",true,false,true,arguments);
        return queue;
    }
 	

	
 	//binding将交换机和相应队列连起来
 	@Bean
 	public Binding bindingtenghw123(){
 		Binding binding=BindingBuilder.bind(directPmcQueue()).to(directPmcExchange()).with("tenghw123");
 		return binding;
 	}
 	

 	
 	
 	
}
